package com.kfm.jdbc.day0325;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;

/**
 * 针对数据库goods表的实体类
 */
public class Goods {


    private Integer goods_no;
    private String goods_name;
    private Double cost;
    private Double price;
    private Integer count;
    private Date createTime;
    private Integer categoryNo;

    public static class GoodsRecover implements  Recover<Goods> {

        @Override
        public List<Goods> recover(ResultSet set) throws SQLException {
            List<Goods> list = new ArrayList<>();
            while (set.next()) {
                // 封装成Goods对象
                Map<String, Object> map = new HashMap<>();
                Goods goods = new Goods();
                goods.setGoods_no(set.getInt(1));
                goods.setGoods_name(set.getString(2));
                goods.setCost(set.getDouble(3));
                goods.setPrice(set.getDouble(4));
                goods.setCount(set.getInt(5));
                goods.setCreateTime(set.getDate(6));
                goods.setCategoryNo(set.getInt(7));
                list.add(goods);
            }
            return list;
        }
    }

    @Override
    public String toString() {
        return "Goods{" +
                "goods_no=" + goods_no +
                ", goods_name='" + goods_name + '\'' +
                ", cost=" + cost +
                ", price=" + price +
                ", count=" + count +
                ", createTime=" + createTime +
                ", categoryNo=" + categoryNo +
                '}';
    }

    public Integer getGoods_no() {
        return goods_no;
    }

    public void setGoods_no(Integer goods_no) {
        this.goods_no = goods_no;
    }

    public String getGoods_name() {
        return goods_name;
    }

    public void setGoods_name(String goods_name) {
        this.goods_name = goods_name;
    }

    public Double getCost() {
        return cost;
    }

    public void setCost(Double cost) {
        this.cost = cost;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Integer getCategoryNo() {
        return categoryNo;
    }

    public void setCategoryNo(Integer categoryNo) {
        this.categoryNo = categoryNo;
    }
}
